<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <!--[if lt IE 7]>
    <div class="ie6_error">还在用<strong>漏洞百出的IE6浏览器</strong>么？为了您的网络安全，请升级浏览器 <a target="_blank"
                                                                               href="http://browsehappy.com">立即升级</a>
    </div>
    <![endif]-->

    <meta charset="utf-8">
    <title>首页-文具1号</title>
    <meta name="description"
          content="文具1号作为上海办公用品供货商公司,专为世界500强企业及SOHO办公族提供网上商城一站式办公耗材批发及采购服务,一站式选购办公日用文具用品,厂家直销,好货又便宜【阳光采购就上文具1号 阳光价格 老板放心 品质保障 员工省力】"/>
    <meta name="keywords" content="办公用品,办公文具,办公文具网站,文具网站,办公用品网,文具采购网,金万年"/>
    <meta name="copyright" content="上海易推信息科技有限公司"/>
    <meta name="renderer" content="webkit">
    <base href="<?php echo base_url(); ?>"/>
    <link rel="stylesheet" type="text/css" href="public/css/base.css"/>
    <link rel="stylesheet" type="text/css" href="public/css/tableexport.min.css"/>
    <script type="text/javascript" src="public/js/jquery.min.js"></script>
    <script type="text/javascript" src="public/js/xlsx.core.min.js"></script>
    <script type="text/javascript" src="public/js/FileSaver.js"></script>
    <script type="text/javascript" src="public/js/jquery.table2excel.js"></script>
    <!--[if lte IE 9]>
    <script type="text/javascript" src="public/js/html5shiv-printshiv-3.js"></script>
    <![endif]-->
    <style>
        body {
            background-color: #f9f9f9;
            font: 12px/1.5 "MicrosoftYaHei", "microsoft yahei", "simhei", "å®‹ä½“", tahoma, arial, sans-serif;
        }

        .bg {
            background-color: #FFFFFF;
            width: 1200px;
            margin: 0 auto;
            overflow: hidden;
            padding: 0px 10px;
        }

        .left {
            height: 100px;
            margin-bottom: 10px
        }

        .left ul {
            height: 30%;
            margin-top: 10px;
        }

        .left ul li {
            float: left;
            margin-right: 5%;
        }

        .hr {
            margin-bottom: 20px;
        }

        .table {
            float: left;
            margin-bottom: 10%
        }

        .table tr {
            border: none;
            border-bottom: none
        }

        .table {
            border-bottom: 1px solid #ccc;
        }

        .button {
            text-align: center;
            margin-left: 10px;
            margin-top: 100px;
            margin-bottom: 20px
        }

        .button button {
            margin-right: 10px;
            background-color: #FFFFFF
        }

        .centen {
            text-align: center;
            vertical-align: middle
        }

        .hide td {
            border: none;
        }

        .bottom {
            margin: 20px;
        }
    </style>
    <script language=javascript>
        function doPrint() {
            $(".tableexport-caption").css('visibility', 'hidden');
            bdhtml = window.document.body.innerHTML;
            sprnstr = "<!--startprint-->"; //开始打印标识字符串有17个字符
            eprnstr = "<!--endprint-->"; //结束打印标识字符串
            prnhtml = bdhtml.substr(bdhtml.indexOf(sprnstr) + 17); //从开始打印标识之后的内容
            prnhtml = prnhtml.substring(0, prnhtml.indexOf(eprnstr)); //截取开始标识和结束标识之间的内容
            window.document.body.innerHTML = prnhtml; //把需要打印的指定内容赋给body.innerHTML
            window.print(); //调用浏览器的打印功能打印指定区域
            window.document.body.innerHTML = bdhtml;//重新给页面内容赋值；
            $(".tableexport-caption").css('visibility', 'visible');
        }
    </script>
</head>
<body>
<div class="bg">
    <div class="button" style="display: none">
        <!--        <button>导出</button>-->
        <input type="button" value="导出">
        <input type="button" onClick="doPrint()" value="打印">
        <!--        <button >打印</button>-->
    </div>
    <br/><br/><br/>
    <div class="hr">
        <div></div>
        <div><img src="public/images/logo.jpg"></div>
    </div>
    <hr/>
    <?php if ($type['type'] == 1): ?>
        <!--startprint-->
        <div class="left" style="display: none">
            <?php if (isset($bill) && isset($customer)): ?>
                <ul>
                    <li><b>帐单号：</b><?php echo $bill['bill_bn'] ?></li>
                    <li><b>账单周期：</b><?php echo $bill['bill_date_from'] ?>~<?php echo $bill['bill_date_to'] ?></li>
                    <li><b>最终还款日：</b><?php echo $bill['should_repayment_date'] ?></li>
                    <li><b>账单总额：</b><?php echo $bill['money'] ?></li>
                </ul>
                <ul>
                    <li><b>公司名称：</b><?php echo $customer['company'] ?></li>
                </ul>
                <ul>
                    <li><b>客户姓名：</b><?php echo $customer['name'] ?></li>
                    <li><b>联系方式：</b><?php echo $customer['tel'] ?></li>
                </ul>
            <?php endif; ?>
        </div>
        <div class="table">
            <table id="table" style="width: 100%">
                <tbody style="">
                <tr class="hide">
                    <td colspan="3"><b>帐单号：</b><?php echo $bill['bill_bn'] ?></td>
                    <td colspan="3"><b>账单周期：</b><?php echo $bill['bill_date_from'] ?>
                        ~<?php echo $bill['bill_date_to'] ?></td>
                    <td colspan="3"><b>最终还款日：</b><?php echo $bill['should_repayment_date'] ?></td>
                    <td colspan="3"><b>账单总额：</b><?php echo $bill['money'] ?></td>
                </tr>
                <tr class="hide">
                    <td colspan="12"><b>公司名称：</b><?php echo $customer['company'] ?></td>
                </tr>
                <tr class="hide">
                    <td colspan="3"><b>客户姓名：</b><?php echo $customer['name'] ?></td>
                    <td colspan="3"><b>联系方式：</b><?php echo $customer['tel'] ?></td>
                    <td colspan="9"></td>
                </tr>
                <tr class="hide">
                    <td colspan="12"></td>
                </tr>
                <tr>
                    <td><b>序号</b></td>
                    <td><b>发票编码</b></td>
                    <td><b>发票抬头</b></td>
                    <td><b>发票金额</b></td>
                    <td><b>开票时间</b></td>
                    <td><b>订单号</b></td>
                    <td><b>订单金额</b></td>
                    <td><b>下单账号</b></td>
                    <td><b>成本中心</b></td>
                    <td><b>联系人</b></td>
                    <td><b>联系方式</b></td>
                    <td><b>支付时间</b></td>
                </tr>

                <?php if (isset($bills)): ?>
                    <?php $i = 0;
                    foreach ($bills['cata'] as $key3 => $cata): ?>
                        <tr>
                            <td><?php echo $key3 + 1 ?></td>
                            <?php if ($i == 0): ?>
                                <!--                                <td rowspan="" class="centen"></td>-->
                                <td rowspan="<?php echo count($bills['cata']) ?>"
                                    class="centen"> <?php echo isset($bills['invoice_bn']) ? $bills['invoice_bn'] : '' ?></td>
                                <td rowspan="<?php echo count($bills['cata']) ?>"
                                    class="centen"><?php echo isset($bills['invoice_title']) ? $bills['invoice_title'] : '' ?></td>
                                <td rowspan="<?php echo count($bills['cata']) ?>"
                                    class="centen"><?php echo isset($bills['invoice_money']) ? $bills['invoice_money'] : '' ?></td>
                                <td rowspan="<?php echo count($bills['cata']) ?>"
                                    class="centen"><?php echo isset($bills['created_at']) ? $bills['created_at'] : '' ?></td>
                            <?php endif; ?>

                            <td class="tableexport-string target"><?php echo $cata['order_bn'] ?></td>
                            <td><?php echo $cata['money'] ?></td>
                            <td><?php echo $cata['username'] ?></td>
                            <td><?php echo $cata['cename'] ?></td>
                            <td><?php echo $cata['cname'] ?></td>
                            <td class="tableexport-string target"><?php echo $cata['tel'] ?></td>
                            <td><?php echo $cata['created_at'] ?></td>
                        </tr>
                        <?php $i++;endforeach; ?>
                <?php endif; ?>
                </tbody>
            </table>
        </div>
        <!--endprint-->
    <?php endif; ?>
</div>


<script type="text/javascript">
    var DefaultTable = document.getElementById('table');
    new TableExport(DefaultTable, {
        headers: true,                              // (Boolean), display table headers (th or td elements) in the <thead>, (default: true)
        footers: true,                              // (Boolean), display table footers (th or td elements) in the <tfoot>, (default: false)
        formats: ['xlsx'],                          // (String[]), filetype(s) for the export, (default: ['xlsx', 'csv', 'txt'])
        filename: '账单详情',                             // (id, String), filename for the downloaded file, (default: 'id')
        bootstrap: false,                           // (Boolean), style buttons using bootstrap, (default: false)
        exportButtons: true,
        position: 'bottom',                         // (top, bottom), position of the caption element relative to table, (default: 'bottom')
        ignoreRows: null,                           // (Number, Number[]), row indices to exclude from the exported file(s) (default: null)
        ignoreCols: null,                           // (Number, Number[]), column indices to exclude from the exported file(s) (default: null)
        ignoreCSS: '.tableexport-ignore',           // (selector, selector[]), selector(s) to exclude cells from the exported file(s) (default: '.tableexport-ignore')
        emptyCSS: '.tableexport-empty',             // (selector, selector[]), selector(s) to replace cells with an empty string in the exported file(s) (default: '.tableexport-empty')
        trimWhitespace: false                        // (Boolean), remove all leading/trailing newlines, spaces, and tabs from cell text in the exported file(s) (default: true)
    });
</script>
<script type="text/javascript">
    $(function () {
        $('.tableexport-caption').append('&nbsp;&nbsp;&nbsp;<button  onClick="doPrint()" class="button-default"> 打印 </button>')

        var ie = (function () {

            var undef,
                v = 3,
                div = document.createElement('div'),
                all = div.getElementsByTagName('i');

            while (
                div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
                    all[0]
                ) ;

            return v > 4 ? v : undef;

        }());
        if ((typeof(ie) == 'undefined') == false) {
            $('body').on('click', '.xlsx', function (event) {
                alert('浏览器版本过低，请更新您的浏览器或使用其他浏览器导出账单');
                event.stopPropagation();
                return false
            })
        }
    })
</script>
</body>
</html>